/*
This file is part of Docking@Home.
http://docking.gcl.cis.udel.edu
Copyright (C) 2009 University of Delaware

Docking@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Docking@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Docking@Home.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Filename: Tab.h
	Description: An abstract class (aka interface) that contains all necessary
		functions that any type of tab must implement.
	Revision History: 
		Created - 01/02/08
	Author: Robert Keller (01/02/08 -> current)
*/

#ifndef _Tab_h
#define _Tab_h

#include "../GLHelper.h"
#include "TabWindow.h"
#include "../GUI_Element_State.h"
#include<stdio.h>
#include<string>
using namespace std;

#define TAB_MAX_NAME_LENGTH 25

class Tab
{

public:

	// Destructor 

	virtual ~Tab() {}
	
	// Static Member Modifiers

	void setTabWindow (TabWindow * t);

	// Member Modifiers

	void setName (const char n[TAB_MAX_NAME_LENGTH]);
	void setNameIndentX (float x);
	void setNameIndentY (float y);

	void select ();
	void unselect ();

	// Set Text Alpha Blending Values

	void setTextSelectedAlpha (float alpha);
	void setTextUnselectedAlpha (float alpha);
	void setTextHoveredAlpha (float alpha);

	// Color Setting Functions

	void setSelectedBoxColor(const float color[4]);
	void setUnselectedBoxColor(const float color[4]);
	void setHoveredBoxColor(const float color[4]);

	void setSelectedTextColor(const float color[4]);
	void setUnselectedTextColor(const float color[4]);

	// Text Property Modifiers

	void setTextColor(const float color[4]);
	void setLineSpacing (float ls);

	// State Determination

	bool determineState (unsigned int index, int curX, 
		int curY, int clicked);

	// Functions that all Tabs need to implement

	virtual void resizeScales (bool bFullscreen = false) = 0;

	virtual void draw (unsigned int index, bool bFullScreen) = 0;
	virtual void drawSelectedTab (unsigned int index) = 0;
	virtual void drawUnselectedTab (unsigned int index) = 0;
	virtual void drawHoveredTab (unsigned int index) = 0;
	virtual void drawTabWindowArea () = 0;
	virtual void drawFullScreen () = 0;

	virtual void handleMouseMove (int x, int y, int left, 
		int middle, int right) = 0;
	virtual void handleMouseButton (int x, int y, int which, 
		int is_down) = 0;
	virtual void handleKeyPress (int key1, int key2) = 0;
	virtual void handleKeyRelease (int key1, int key2) = 0;

protected:

	// Constructor 

	Tab ();

	// Calculate Location Values

	void getTabStart (unsigned int index, float * tabStartX, 
		float * tabStartY);

	// Required Variables

	static GLHelper * glHelper;
	static TabWindow * tabWindow;

	// Tab Properties

	char name[TAB_MAX_NAME_LENGTH];
	float nameIndentX;
	float nameIndentY;

	float textSelectedAlpha;
	float textUnselectedAlpha;
	float textHoveredAlpha;

	// Tab Colors

	float selectedBoxColor[4];
	float unselectedBoxColor[4];
	float hoveredBoxColor[4];

	float selectedTextColor[4];
	float unselectedTextColor[4];

	// Text Properties
	float textColor[4];
	float lineSpacing;

	float textXScale;
	float textYScale;

	float textStandardXScale;
	float textStandardYScale;

	// Tab State

	GUI_Element_State state;

	bool bSelected;

	// Size Properties
	float width;
	float height;

	// Scale Factors
	float tabScaleTextX;
	float tabScaleTextY;
	
	// Constant positioning / sizing variables
		
	const static float TAB_WIDTH;
	const static float TAB_HEIGHT;
	const static float TAB_SPACING;

	const static float TAB_X_SCALE_FACTOR;
	const static float TAB_Y_SCALE_FACTOR;
};

#endif
